home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_483 / butexchange / butexchange.asm < prev    next >
Assembly Source File  |  1992-05-06  |  17KB  |  664 lines

  1. *    ButExchange V1.0
  2. *    By Preben Nielsen
  3. *
  4. *      This program is intended as a help to left-handed Amiga-users.
  5. *    It installes an input-handler which reverses the function of the
  6. *    mouse buttons, so that the left button becomes the right and
  7. *    vice versa.
  8. *
  9. *      Once installed, the program only uses 168 bytes of memory. To
  10. *    get back to normal simply run the program again.
  11. *
  12. *    NOTE:    There's no need to 'RUN' or 'RUNBACK' this program from the
  13. *        CLI. It terminates immediately.
  14. *
  15. *HISTORY
  16. *          Made with Hisoft V2.12
  17. *
  18. *  V1.0   09-Apr-91: First attempt. Works of course
  19.                    
  20.     OPT O+
  21.     OPT O1+            ; Tells when a branch could be optimised to short
  22.     OPT i+            ; Tells when '#' is probably missing
  23.  
  24.         incdir        "AsmInc:"
  25.         include        "exec/exec_lib.i"
  26.         include        "exec/io.i"
  27.         include        "exec/memory.i"
  28.         include        "exec/interrupts.i"
  29.         include        "devices/input.i"
  30.         include        "devices/inputevent.i"
  31.         include        "libraries/dosextens.i"
  32.         include        "libraries/dos_lib.i"
  33.  
  34. Prepare        MACRO
  35.         IFC        '\1','Exec_Call'
  36.         movea.l        4.W,A6
  37.         ENDC
  38.         IFC        '\1','Intuition_Call'
  39.         movea.l        IntBase(DB),A6
  40.         ENDC
  41.         IFC        '\1','Gfx_Call'
  42.         movea.l        GfxBase(DB),A6
  43.         ENDC
  44.         IFC        '\1','Dos_Call'
  45.         movea.l        DosBase(DB),A6
  46.         ENDC
  47.         ENDM
  48. CallLib        MACRO
  49.         jsr        _LVO\1(A6)
  50.         ENDM
  51. Call        MACRO
  52.         bsr        \1
  53.         ENDM
  54. CallS        MACRO
  55.         bsr.S        \1
  56.         ENDM
  57. Push        MACRO
  58.         movem.l        \1,-(SP)
  59.         ENDM
  60. Pop        MACRO
  61.         movem.l        (SP)+,\1
  62.         ENDM
  63. rAPtr        MACRO        name
  64. DefSiz        set        DefSiz+4
  65. DefPtr        set        DefPtr-4
  66. \1        =        DefPtr
  67.         ENDM
  68. rLong        MACRO        name
  69. DefSiz        set        DefSiz+4
  70. DefPtr        set        DefPtr-4
  71. \1        =        DefPtr
  72.         ENDM
  73. rWord        MACRO        name
  74. DefSiz        set        DefSiz+2
  75. DefPtr        set        DefPtr-2
  76. \1        =        DefPtr
  77.         ENDM
  78. rByte        MACRO        name
  79. DefSiz        set        DefSiz+1
  80. DefPtr        set        DefPtr-1
  81. \1        =        DefPtr
  82.         ENDM
  83. rStorage    MACRO        name,size    ; Define storage
  84. DefSiz        set        DefSiz+\2
  85. DefPtr        set        DefPtr-\2
  86. \1        =        DefPtr
  87.         ENDM
  88. rEVEN        MACRO                ; Word boundary
  89.         IFNE        DefPtr&1
  90. DefPtr        set        DefPtr-1
  91. DefSiz        set        DefSiz+1
  92.         ENDC
  93.         ENDM
  94. rStart        MACRO                ; Define var section
  95. DefPtr        set        0
  96. DefSiz        set        0
  97.         ENDM
  98. rEnd        MACRO                ; End var section
  99. RelSize        =        DefSiz
  100.         ENDM
  101. rAlloc        MACRO                ; Allocate vars
  102.         link        DB,#-RelSize
  103.         ENDM
  104. rFree        MACRO                ; Deallocate vars
  105.         unlk        DB
  106.         ENDM
  107. rClear        MACRO                ; Reset all vars
  108.         movem.l        D0/DB,-(SP)
  109.         move.w        #RelSize-1,D0
  110. rClr.\@        clr.b        -(DB)
  111.         dbf        D0,rClr.\@
  112.         movem.l        (SP)+,D0/DB
  113.         ENDM
  114.  
  115. DB        EQUR        A4
  116.  
  117.         SECTION        ButExchange,CODE
  118. InitProcess    rAlloc                    ; Allocate memory for variables
  119.         rClear                    ; Clear the memory
  120.         Prepare        Exec_Call
  121.         suba.l        A1,A1
  122.         CallLib        FindTask        ; Find us
  123.         move.l        D0,PProcess(DB)
  124.         movea.l        D0,A2
  125.         tst.l        pr_CLI(A2)
  126.         bne.S        GetLibs
  127. WBStart        lea        pr_MsgPort(A2),A0
  128.         CallLib        WaitPort        ; wait for a message
  129.         lea        pr_MsgPort(A2),A0
  130.         CallLib        GetMsg            ; then get it
  131.         move.l        D0,WBMsg(DB)        ; save it for later reply
  132. GetLibs        lea        DosName(PC),A1
  133.         CallLib        OldOpenLibrary
  134.         move.l        D0,DosBase(DB)
  135.         beq.S        Error
  136.  
  137.         CallLib        Forbid
  138.         lea        IHS(PC),A1
  139.         lea        ihs_PortName(A1),A1
  140.         CallLib        FindPort
  141.         move.l        D0,D2
  142.         CallLib        Permit
  143.         move.l        D2,D0            ; Does Forbid/Permit destroy scratch-registers ?
  144.         beq.S        DoInstall
  145. DoRemove    moveq        #REMOVED,D7
  146.         lea        IHS(PC),A0
  147.         lea        PSEndIHS1(PC),A1
  148.         lea        PSEndIHS2(PC),A2
  149.         Call        RemoveHandler
  150.         beq.S        ShowMsg
  151.         moveq        #CANTREMOVE,D7
  152.         bra.S        ShowMsg
  153. DoInstall    moveq        #INSTALLED,D7
  154.         lea        IHS(PC),A0
  155.         lea        PSPrepIHS1(PC),A1
  156.         lea        PSPrepIHS2(PC),A2
  157.         Call        InstallHandler
  158.         beq.S        ShowMsg
  159.         moveq        #CANTINSTALL,D7
  160. ShowMsg        move.l        D7,D0
  161.         Call        CONMsg
  162.  
  163. Error
  164. Exit        Prepare        Exec_Call
  165. FreeDos        move.l        DosBase(DB),D0
  166.         beq.S        ReplyWB
  167.         move.l        D0,A1
  168.         CallLib        CloseLibrary
  169. ReplyWB        move.l        WBMsg(DB),D2
  170.         beq.S        AllDone
  171.         CallLib        Forbid            ; We were started from WB
  172.         movea.l        D2,A1
  173.         CallLib        ReplyMsg        ; Reply WBMessage
  174. AllDone        rFree
  175.         moveq        #0,D0
  176.         rts
  177.  
  178. FHandle        EQUR        D5
  179. * Call: D0 = Msg-number
  180. CONMsg        Push        D0-D7/A0-A6
  181.         Prepare        Dos_Call
  182.         move.l        D0,D4
  183.         moveq        #0,D6
  184.         CallLib        Output
  185.         move.l        D0,FHandle
  186.         bne.S        1$
  187.         moveq        #1,D6
  188.         lea        CONName(PC),A0
  189.         move.l        A0,D1
  190.         move.l        #MODE_OLDFILE,D2
  191.         CallLib        Open
  192.         move.l        D0,FHandle
  193.         beq.S        2$
  194. 1$        moveq        #INFOMSG,D0
  195.         Call        SendMsg
  196.         move.l        D4,D0
  197.         Call        SendMsg
  198.         tst.l        D6
  199.         beq.S        2$
  200.         moveq        #127,D1
  201.         CallLib        Delay
  202.         move.l        FHandle,D1
  203.         CallLib        Close
  204. 2$        Pop        D0-D7/A0-A6
  205.         rts
  206.  
  207. * Call: D0 = Msg-number
  208. SendMsg        neg.l        D0
  209.         lsl.l        #1,D0
  210.         lea        MsgTable(PC),A0
  211.         add.w        0(A0,D0),A0
  212.         move.l        A0,D2
  213.         moveq        #-1,D3
  214. 1$        addq.l        #1,D3
  215.         tst.b        (A0)+
  216.         bne.S        1$
  217.         move.l        FHandle,D1
  218.         Prepare        Dos_Call
  219.         CallLib        Write
  220.         rts
  221.  
  222. INFOMSG        =0
  223. INSTALLED    =-1
  224. REMOVED        =-2
  225. CANTINSTALL    =-3
  226. CANTREMOVE    =-4
  227.  
  228. MsgText        MACRO
  229.         dc.w        \1-MsgTable
  230.         ENDM
  231. MsgTable    MsgText        Msg
  232.         MsgText        Msg1
  233.         MsgText        Msg2
  234.         MsgText        Msg3
  235.         MsgText        Msg4
  236.  
  237. CONName        dc.b        'CON:100/60/330/63/ButExchange',0
  238. Msg        dc.b        10,$9B,'0;33m ButExchange V1.0',10
  239.         dc.b        $9B,'0;31m 1991 by ',$9B,'0;33mPreben Nielsen',$9B,'0;31m',10,' ',0
  240. Msg1        dc.b        'has just been installed...',10,0
  241. Msg2        dc.b        'has just been removed...',10,0
  242. Msg3        dc.b        'Error: Cannot install handler',10,0
  243. Msg4        dc.b        'Error: Cannot remove handler',10,0
  244.         EVEN
  245.  
  246. rtsValue    EQUR        D7
  247. * This is general-purpose inputhandler removal-routine
  248. * It only needs an ihs with a port-name to remove the handler
  249. * Call:   A0 = ihs
  250. *      A1 = first ihs-installation-routine or NULL
  251. *      A2 = second ihs-installation-routine or NULL
  252. * Return: D0 = 0 means succes
  253. RemoveHandler    Push        D1/rtsValue/A0-A3/A6
  254.         moveq        #-1,rtsValue
  255.         move.l        A2,A3
  256.         move.l        A0,A2
  257.         move.l        A1,D1
  258.         beq.S        1$
  259.         jsr        (A1)        ; A0 = ihs
  260.         beq.S        2$
  261.         move.l        D0,A2
  262. 1$        move.l        A2,A0
  263.         Prepare        Exec_Call
  264.         moveq        #IND_REMHANDLER,D0
  265.         Call        TellInputDevice
  266.         move.l        D0,rtsValue
  267.         bne.S        2$
  268.         lea        ihs_Port(A2),A1
  269.         CallLib        RemPort
  270.         moveq        #0,D0
  271.         bra.S        3$
  272. 2$        moveq        #-1,D0
  273. 3$        move.l        A3,D1
  274.         beq.S        4$
  275.         move.l        A2,A0
  276.         jsr        (A3)        ; A0 = ihs, D0 = 0 means succes
  277. 4$        move.l        rtsValue,D0
  278.         Pop        D1/rtsValue/A0-A3/A6
  279.         rts
  280.  
  281. * This is general-purpose inputhandler installation-routine
  282. * It only needs an ihs with a port-name to install the handler
  283. * Call:   A0 = ihs
  284. *      A1 = first ihs-installation-routine or NULL
  285. *      A2 = second ihs-installation-routine or NULL
  286. * Return: D0 = 0 means succes
  287. InstallHandler    Push        D1/rtsValue/A0-A3/A6
  288.         moveq        #-1,rtsValue
  289.         move.l        A2,A3
  290.         move.l        A0,A2
  291.         move.l        A1,D1
  292.         beq.S        1$
  293.         jsr        (A1)        ; A0 = ihs
  294.         beq.S        2$
  295.         move.l        D0,A2
  296. 1$        move.l        A2,A0
  297.         moveq        #IND_ADDHANDLER,D0
  298.         Call        TellInputDevice
  299.         move.l        D0,rtsValue
  300.         bne.S        2$
  301.         lea        ihs_Port(A2),A1
  302.         lea        ihs_PortName(A2),A0
  303.         move.l        A0,MP+LN_NAME(A1)        ;MsgPort->mp_Node.ln_Name=Name;
  304.         clr.b        MP+LN_PRI(A1)            ;MsgPort->mp_Node.ln_Pri =0;
  305.         move.b        #NT_MSGPORT,MP+LN_TYPE(A1)    ;MsgPort->mp_Node.ln_Type=NT_MSGPORT;
  306.         move.b        #PA_IGNORE,MP_FLAGS(A1)        ;MsgPort->mp_Flags     =PA_IGNORE;
  307.         Prepare        Exec_Call
  308.         CallLib        AddPort
  309.         moveq        #0,D0
  310.         bra.S        3$
  311. 2$        moveq        #-1,D0
  312. 3$        move.l        A3,D1
  313.         beq.S        4$
  314.         move.l        A2,A0
  315.         jsr        (A3)        ; A0 = ihs, D0 = 0 means succes
  316. 4$        move.l        rtsValue,D0
  317.         Pop        D1/rtsValue/A0-A3/A6
  318.         rts
  319.  
  320. * Open the input device. Set up the I/O block to add or remove the
  321. * input handler, and send the request to the input device. Finally,
  322. * close the device
  323. * Call:   A0 = ihs
  324. *      D0 = Function to perform (IND_ADDHANDLER/IND_REMHANDLER)
  325. * Return: D0 = 0 means succes
  326. TellInputDevice    Push        D1-D2/rtsValue/A0-A3/A6
  327.         Prepare        Exec_Call
  328.         moveq        #-1,rtsValue
  329.         move.l        D0,D2
  330.         move.l        A0,A2
  331.         lea        IReq(DB),A0
  332.         moveq        #IOSTD_SIZE,D0
  333.         Call        MemClear
  334.         lea        IPort(DB),A0
  335.         moveq        #MP_SIZE,D0
  336.         Call        MemClear
  337.         move.l        A0,A3
  338.         move.b        #NT_MSGPORT,MP+LN_TYPE(A3)    ; mp_Node.ln_Type=NT_MSGPORT;
  339.         move.b        #PA_SIGNAL,MP_FLAGS(A3)        ; mp_Flags    =PA_SIGNAL;
  340.         moveq        #-1,D0
  341.         CallLib        AllocSignal
  342.         move.b        D0,MP_SIGBIT(A3)        ; mp_SigBit    =MPSigBit;
  343.         bmi.S        2$
  344.         suba.l        A1,A1
  345.         CallLib        FindTask
  346.         move.l        D0,MP_SIGTASK(A3)        ; mp_SigTask     =FindTask(0);
  347.         lea        IReq(DB),A1
  348.         move.l        A3,IO+MN_REPLYPORT(A1)        ; ExtReq->io_Message.mn_ReplyPort   =taskReplyPort;
  349.         move.b        #NT_MESSAGE,IO+MN+LN_TYPE(A1)    ; ExtReq->io_Message.mn_Node.ln_Type=NT_MESSAGE;
  350.         lea        InputName(PC),A0        ; input.device
  351.         moveq        #0,D0                ; unit#
  352.         moveq        #0,D1                ; flags
  353.         CallLib        OpenDevice
  354.         tst.w        D0                ; flag: error if > 0
  355.         bne.S        1$
  356.         lea        IReq(DB),A1
  357.         move.w        D2,IO_COMMAND(A1)
  358.         lea        ihs_Interrupt(A2),A0
  359.         move.l        A0,IO_DATA(A1)
  360.         CallLib        DoIO
  361.         move.l        D0,rtsValue
  362.         lea        IReq(DB),A1
  363.         CallLib        CloseDevice
  364. 1$        move.b        MP_SIGBIT(A3),D0
  365.         CallLib        FreeSignal
  366. 2$        move.l        rtsValue,D0
  367.         Pop        D1-D2/rtsValue/A0-A3/A6
  368.         rts
  369.  
  370. * Call: A0    = Memory area
  371. *    D0:16 = Count
  372. MemClear    Push        D0-D1/A0
  373.         moveq        #0,D1
  374.         bra.S        2$
  375. 1$        move.b        D1,(A0)+
  376. 2$        dbf        D0,1$
  377.         Pop        D0-D1/A0
  378.         rts
  379.  
  380. * Call: A0   = Source
  381. *    A1   = Destination
  382. *    D0:16= Count
  383. MemCopy        Push        D0/A0-A1
  384.         bra.S        2$
  385. 1$        move.b        (A0)+,(A1)+
  386. 2$        dbf        D0,1$
  387.         Pop        D0/A0-A1
  388.         rts
  389.  
  390. * Each handler should have such a pair of installation-routine
  391. * The first one is passed to InstallHandler in A1 and it
  392. * is called immediately when entering InstallHandler
  393. * The second one is passed to InstallHandler in A2 and it
  394. * is called after attempt to install handler and message-port
  395. * -----------------------------------------------------------------
  396. * Call:   A0 = ihs
  397. * Return: D0 has to point to ihs to be used when installation proceeds
  398. *      If D0 = 0 then installation is aborted
  399. PSPrepIHS1    Push        D1/A0-A1/A6
  400.         Prepare        Exec_Call
  401.         move.l        #HandlerSize,D0
  402.         move.l        #MEMF_PUBLIC|MEMF_CLEAR,D1
  403.         CallLib        AllocMem
  404.         move.l        D0,HMem(DB)
  405.         beq.S        2$
  406.         move.l        D0,A1
  407.         lea        IHS(PC),A0
  408.         move.l        #HandlerSize,D0
  409.         Call        MemCopy
  410.         move.l        D0,ihs_Length(A1)        ; This will enable removal by other programs
  411.         lea        HandlerCode-IHS(A1),A0
  412.         move.l        A0,ihs_Interrupt+IS_CODE(A1)    ; HandlerBlock.HInterrupt.is_Code = Handler
  413.         clr.l        ihs_Interrupt+IS_DATA(A1)    ; HandlerBlock.HInterrupt.is_Data = 0
  414.         move.b        #HPRI,ihs_Interrupt+LN_PRI(A1)    ; HandlerBlock.HInterrupt.is_Node.ln_Pri = PRI
  415.         move.l        A1,D0
  416. 2$        Pop        D1/A0-A1/A6
  417.         rts
  418.  
  419. * Call:   A0 = ihs
  420. *         D0 = 0 means everything went perfect
  421. *             -1 means something went wrong during installation
  422. PSPrepIHS2    Push        D0-D1/A0-A1/A6
  423.         tst.l        D0
  424.         beq.S        1$
  425.         move.l        HMem(DB),D0
  426.         beq.S        1$
  427.         move.l        D0,A1
  428.         move.l        #HandlerSize,D0
  429.         Prepare        Exec_Call
  430.         CallLib        FreeMem
  431. 1$        Pop        D0-D1/A0-A1/A6
  432.         rts
  433.  
  434. * Each handler should have such a pair of ending-routine
  435. * The first one is passed to RemoveHandler in A1 and it
  436. * is called immediately when entering RemoveHandler
  437. * The second one is passed to RemoveHandler in A2 and it
  438. * is called after attempt to remove handler and message-port
  439. * -----------------------------------------------------------------
  440. * Call:   A0 = ihs
  441. * Return: D0 has to point to ihs to be used when removal proceeds
  442. *      If D0 = 0 then removal is aborted
  443. PSEndIHS1    Push        D1-D2/A0-A1/A6
  444.         Prepare        Exec_Call
  445.         CallLib        Forbid
  446.         lea        ihs_PortName(A0),A1
  447.         CallLib        FindPort
  448.         move.l        D0,D2
  449.         CallLib        Permit
  450.         move.l        D2,D0            ; Does Forbid/Permit destroy scratch-registers ?
  451.         Pop        D1-D2/A0-A1/A6
  452.         rts
  453. * Call:   A0 = ihs
  454. *         D0 = 0 means everything went perfect
  455. *             -1 means something went wrong during removal
  456. PSEndIHS2    Push        D0-D1/A0-A1/A6
  457.         tst.l        D0
  458.         bmi.S        1$
  459.         Prepare        Exec_Call
  460.         move.l        ihs_Length(A0),D0
  461.         move.l        A0,A1
  462.         CallLib        FreeMem
  463. 1$        Pop        D0-D1/A0-A1/A6
  464.         rts
  465.  
  466. *====================== Input-handler start =========================
  467. ihs_Port    =0
  468. ihs_Interrupt    =MP_SIZE
  469. ihs_ID        =MP_SIZE+IS_SIZE
  470. ihs_Length    =MP_SIZE+IS_SIZE+4
  471. ihs_Flags    =MP_SIZE+IS_SIZE+8
  472. ihs_PortName    =MP_SIZE+IS_SIZE+10
  473.  
  474. ihs_Start    MACRO
  475.         dcb.b        MP_SIZE        ; Message-Port structure
  476.         dcb.b        IS_SIZE        ; Interrupt structure
  477.         dc.l        'P_IH'        ; ID (Handler made by me)
  478.         dc.l        0        ; Length of handler 
  479.         dc.w        0        ; Flags
  480.         dc.b        \1,0
  481.         EVEN
  482.         ENDM
  483.  
  484. HPRI        =127                ; Handler-priority
  485. HDisabled    =0
  486. HNoExtRemoval    =1                ; Future
  487.  
  488. * This is the handler-block
  489. IHS        ihs_Start    <'ButExchange V1.0 Port'>
  490. * For each event in the event list:
  491. *  If it is LMB event then make it a RMB event and vice versa.
  492. * When all the events have been checked, return the event list so that
  493. * others can do their things.
  494. EList        EQUR    A0
  495. Event        EQUR    A1
  496.  
  497. Next        =ie_NextEvent
  498. Class        =ie_Class
  499. Code        =ie_Code
  500. Qual        =ie_Qualifier
  501.  
  502. * Call:  A0 = List of InputEvents, A1 = HandlerData
  503. HandlerCode    Push        D1/Event/EList
  504.         move.w        IHS+ihs_Flags(PC),D0
  505.         btst        #HDisabled,D0        ; Future feature
  506.         bne.S        NoMoreEvents
  507.         move.l        EList,Event
  508. ieLoop        move.l        Event,D0
  509.         beq.S        NoMoreEvents
  510.         cmpi.b        #IECLASS_RAWMOUSE,Class(Event)
  511.         bne.S        DontRemove
  512.         move.w        Code(Event),D0
  513.         move.w        D0,D1
  514.         andi.w        #IECODE_UP_PREFIX,D1
  515.         andi.w        #~IECODE_UP_PREFIX,D0
  516.         cmpi.w        #IECODE_LBUTTON,D0
  517.         beq.S        ExchangeLR
  518.         cmpi.w        #IECODE_RBUTTON,D0
  519.         bne.S        DontRemove
  520. ExchangeRL    ori.w        #IECODE_LBUTTON,D1
  521.         bra.S        Exchanged
  522. ExchangeLR    ori.w        #IECODE_RBUTTON,D1
  523. Exchanged    move.w        D1,Code(Event)
  524. * Just move on to next Event
  525. DontRemove    move.l        Next(Event),Event
  526.         bra.S        ieLoop
  527. * Lets return
  528. NoMoreEvents    move.l        EList,D0
  529.         Pop        D1/Event/EList
  530.         rts
  531. HandlerSize    =        *-IHS
  532. *====================== Input-handler end ===========================
  533.  
  534. *====================== Data-definition start =======================
  535.  rStart
  536.  rAPtr        PProcess
  537.  rAPtr        WBMsg
  538.  rAPtr        DosBase
  539.  rStorage    IReq,IOSTD_SIZE
  540.  rStorage    IPort,MP_SIZE
  541.  rAPtr        HMem
  542.  rEnd
  543.  
  544. DosName        dc.b        'dos.library',0
  545. InputName    dc.b        'input.device',0
  546.         END
  547.  
  548. * These defines are here for quick reference only
  549.  --- InputEvent.ie_Class ---
  550. IECLASS_NULL        0x00    A NOP input event
  551. IECLASS_RAWKEY        0x01    A raw keycode from the keyboard device
  552. IECLASS_RAWMOUSE    0x02    The raw mouse report from the game port device
  553. IECLASS_EVENT        0x03    A private console event
  554. IECLASS_POINTERPOS    0x04    A Pointer Position report
  555. IECLASS_TIMER        0x06    A timer event
  556. IECLASS_GADGETDOWN    0x07    select button pressed down over a Gadget (address in ie_EventAddress)
  557. IECLASS_GADGETUP    0x08    select button released over the same Gadget (address in ie_EventAddress)
  558. IECLASS_REQUESTER    0x09    some Requester activity has taken place.  See Codes REQCLEAR and REQSET
  559. IECLASS_MENULIST    0x0A    this is a Menu Number transmission (Menu number is in ie_Code)
  560. IECLASS_CLOSEWINDOW    0x0B    User has selected the active Window's Close Gadget
  561. IECLASS_SIZEWINDOW    0x0C    this Window has a new size
  562. IECLASS_REFRESHWINDOW    0x0D    the Window pointed to by ie_EventAddress needs to be refreshed
  563. IECLASS_NEWPREFS    0x0E    new preferences are available
  564. IECLASS_DISKREMOVED    0x0F    the disk has been removed
  565. IECLASS_DISKINSERTED    0x10    the disk has been inserted
  566. IECLASS_ACTIVEWINDOW    0x11    the window is about to be made active
  567. IECLASS_INACTIVEWINDOW    0x12    the window is about to be made inactive
  568. IECLASS_MAX        0x12    the last class
  569.  
  570.   --- InputEvent.ie_Code ---
  571. IECLASS_RAWKEY
  572. IECODE_UP_PREFIX    0x80
  573. IECODE_KEY_CODE_FIRST    0x00
  574. IECODE_KEY_CODE_LAST    0x77
  575. IECODE_COMM_CODE_FIRST    0x78
  576. IECODE_COMM_CODE_LAST    0x7F
  577.   
  578. IECLASS_ANSI
  579. IECODE_C0_FIRST        0x00
  580. IECODE_C0_LAST        0x1F
  581. IECODE_ASCII_FIRST    0x20
  582. IECODE_ASCII_LAST    0x7E
  583. IECODE_ASCII_DEL    0x7F
  584. IECODE_C1_FIRST        0x80
  585. IECODE_C1_LAST        0x9F
  586. IECODE_LATIN1_FIRST    0xA0
  587. IECODE_LATIN1_LAST    0xFF
  588.   
  589. IECLASS_RAWMOUSE
  590. IECODE_LBUTTON        0x68    also uses IECODE_UP_PREFIX
  591. IECODE_RBUTTON        0x69
  592. IECODE_MBUTTON        0x6A
  593. IECODE_NOBUTTON        0xFF
  594.   
  595. IECLASS_EVENT
  596. IECODE_NEWACTIVE    0x01    active input window changed
  597.  
  598. IECLASS_REQUESTER Codes
  599. REQSET is broadcast when the first Requester (not subsequent ones) opens
  600. in the Window
  601.  
  602. IECODE_REQSET        0x01
  603. REQCLEAR is broadcast when the last Requester clears out of the Window
  604. IECODE_REQCLEAR        0x00
  605.  
  606.  --- InputEvent.ie_Qualifier ---
  607. IEQUALIFIER_LSHIFT        0x0001
  608. IEQUALIFIER_RSHIFT        0x0002
  609. IEQUALIFIER_CAPSLOCK        0x0004
  610. IEQUALIFIER_CONTROL        0x0008
  611. IEQUALIFIER_LALT        0x0010
  612. IEQUALIFIER_RALT        0x0020
  613. IEQUALIFIER_LCOMMAND        0x0040
  614. IEQUALIFIER_RCOMMAND        0x0080
  615. IEQUALIFIER_NUMERICPAD        0x0100
  616. IEQUALIFIER_REPEAT        0x0200
  617. IEQUALIFIER_INTERRUPT        0x0400
  618. IEQUALIFIER_MULTIBROADCAST    0x0800
  619. IEQUALIFIER_MIDBUTTON        0x1000
  620. IEQUALIFIER_RBUTTON        0x2000
  621. IEQUALIFIER_LEFTBUTTON        0x4000
  622. IEQUALIFIER_RELATIVEMOUSE    0x8000
  623.  
  624. IEQUALIFIERB_LSHIFT        0
  625. IEQUALIFIERB_RSHIFT        1
  626. IEQUALIFIERB_CAPSLOCK        2
  627. IEQUALIFIERB_CONTROL        3
  628. IEQUALIFIERB_LALT        4
  629. IEQUALIFIERB_RALT        5
  630. IEQUALIFIERB_LCOMMAND        6
  631. IEQUALIFIERB_RCOMMAND        7
  632. IEQUALIFIERB_NUMERICPAD        8
  633. IEQUALIFIERB_REPEAT        9
  634. IEQUALIFIERB_INTERRUPT        10
  635. IEQUALIFIERB_MULTIBROADCAST    11
  636. IEQUALIFIERB_MIDBUTTON        12
  637. IEQUALIFIERB_RBUTTON        13
  638. IEQUALIFIERB_LEFTBUTTON        14
  639. IEQUALIFIERB_RELATIVEMOUSE    15
  640.   
  641. struct InputEvent
  642. {
  643.  struct  InputEvent *ie_NextEvent    ;the chronologically next event
  644.  UBYTE   ie_Class            ;the input event class
  645.  UBYTE   ie_SubClass            ;optional subclass of the class
  646.  UWORD   ie_Code            ;the input event code
  647.  UWORD   ie_Qualifier            ;qualifiers in effect for the event
  648.  union
  649.   {
  650.    struct
  651.     {
  652.      WORD    ie_x            ;the pointer position for the event
  653.      WORD    ie_y
  654.     } ie_xy
  655.    APTR    ie_addr
  656.   } ie_position
  657.   struct timeval ie_TimeStamp        ;the system tick at the event
  658. };
  659.  
  660. ie_X            =ie_position.ie_xy.ie_x
  661. ie_Y            =ie_position.ie_xy.ie_y
  662. ie_EventAddress        =ie_position.ie_addr
  663.  
  664.